package com;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class LedgerReportServlet
 */
public class LedgerReportServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public LedgerReportServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		String value1=request.getParameter("vouchernumber");
		System.out.println("Voucher Number-"+value1);
				
		String value2=request.getParameter("group");
		System.out.println("Voucher Type-"+value2);
		
		
			
		if(value2.equals("Sales"))
		{
			request.setAttribute("vnumber",value1);
			request.setAttribute("vtype",value2);
	        RequestDispatcher requestDispatcher; 
	        requestDispatcher = request.getRequestDispatcher("EditSalesVoucher.jsp" ) ;
	        requestDispatcher.forward(request,response);
		}
		else if(value2.equals("Credit"))
		{
			request.setAttribute("vnumber",value1);
			request.setAttribute("vtype",value2);
	        RequestDispatcher requestDispatcher; 
	        requestDispatcher = request.getRequestDispatcher("EditCreditNote.jsp" ) ;
	        requestDispatcher.forward(request,response);
		}
		else if(value2.equals("Purchase"))
		{
			request.setAttribute("vnumber",value1);
			request.setAttribute("vtype",value2);
	        RequestDispatcher requestDispatcher; 
	        requestDispatcher = request.getRequestDispatcher("EditPurchaseVoucher.jsp" ) ;
	        requestDispatcher.forward(request,response);
		}
		else if(value2.equals("Debit"))
		{
			request.setAttribute("vnumber",value1);
			request.setAttribute("vtype",value2);
	        RequestDispatcher requestDispatcher; 
	        requestDispatcher = request.getRequestDispatcher("EditDebitNote.jsp" ) ;
	        requestDispatcher.forward(request,response);
		}
		else if(value2.equals("Receipts"))
		{
			request.setAttribute("vnumber",value1);
			request.setAttribute("vtype",value2);
			RequestDispatcher requestDispatcher; 
			requestDispatcher = request.getRequestDispatcher("EditReceiptsVoucher.jsp" ) ;
			requestDispatcher.forward(request,response);
		}
		else if(value2.equals("Payment"))
		{
			request.setAttribute("vnumber",value1);
			request.setAttribute("vtype",value2);
			RequestDispatcher requestDispatcher; 
			requestDispatcher = request.getRequestDispatcher("EditPaymentVoucher.jsp" ) ;
			requestDispatcher.forward(request,response);
		}
		else if(value2.equals("Journal"))
		{
			request.setAttribute("vnumber",value1);
			request.setAttribute("vtype",value2);
			RequestDispatcher requestDispatcher; 
			requestDispatcher = request.getRequestDispatcher("EditJournalVoucher.jsp" ) ;
			requestDispatcher.forward(request,response);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
